package com.nbstar.film.spider.engine;

import com.nbstar.film.spider.domain.FilmSpiderDomain;
import com.nbstar.film.spider.excel.CommonExcelReader;
import com.nbstar.film.spider.excel.SiChuanExcelReader;
import com.nbstar.film.spider.excel.SiChuanExcelWriter;
import com.nbstar.film.spider.spider.BaseSpider;
import com.nbstar.film.spider.spider.SpiderFactory;
import com.nbstar.film.spider.thread.ProxyThread;
import lombok.Data;

@Data
public class SCSpiderEngineV2 extends SCSpiderEngine {

    private int nameIndex = 0;
    private int seqIndex = 0;

    @Override
    public void initEngine() {
        registSpider(FilmSpiderDomain.SPIDER_FROM_DOUBAN, (BaseSpider) SpiderFactory.create(FilmSpiderDomain.SPIDER_FROM_DOUBAN));
        registSpider(FilmSpiderDomain.SPIDER_FROM_IMDB, (BaseSpider) SpiderFactory.create(FilmSpiderDomain.SPIDER_FROM_IMDB));
        registSpider(FilmSpiderDomain.SPIDER_FROM_TVMAO_TV, (BaseSpider) SpiderFactory.create(FilmSpiderDomain.SPIDER_FROM_TVMAO_TV));
        registSpider(FilmSpiderDomain.SPIDER_FROM_MAOYAN, (BaseSpider) SpiderFactory.create(FilmSpiderDomain.SPIDER_FROM_MAOYAN));
        registSpider(FilmSpiderDomain.SPIDER_FROM_BAIKE, (BaseSpider) SpiderFactory.create(FilmSpiderDomain.SPIDER_FROM_BAIKE));
        //获取代理
        ProxyThread proxyThread = new ProxyThread();
        proxyThread.start();
        CommonExcelReader commonExcelReader = new CommonExcelReader();
        commonExcelReader.setColIndex(nameIndex);
        //commonExcelReader.setReadSeqNo(true);
        commonExcelReader.setSeqNoIdex(seqIndex);
        this.excelReader = commonExcelReader;

        this.excelWriter = new SiChuanExcelWriter(resultSheetName, resultExcelName);

        excelReader.setFilmSpiderQueue(filmSpiderQueue);
    }
}
